import React from 'react'
import {connect } from 'react-redux'
import { bindActionCreators} from 'redux'

import * as userinfoActions from './actions-userinfo.jsx'

import A from './a.jsx'
import B from './b.jsx'
import C from './c.jsx'



class Hello extends React.Component{
    render() {
        return (
            <div>
                <p>hello world</p>
                <hr/>
                <A userinfo = {this.props.userinfo}></A>
                <hr/>
                <B userinfo = {this.props.userinfo}></B>
                <hr/>
                <C actions = {this.props.aa}></C>
            </div>
        )
    }

    componentDidMount() {
        this.props.aa.login({
            userid: 'abc',
            city: 'beijing'
        })
    }
}

function mapStateToProps(state) {
    return {
        userinfo: state.bb
    }
}

function mapDispatchToProps(dispatch) {
    return {
        aa: bindActionCreators(userinfoActions, dispatch)
    }
}

export default connect(
    mapStateToProps,
    mapDispatchToProps
)(Hello)